﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using Function;
using System.Data;
using System.Threading;

namespace UI.Module.InvestmentIncome
{
    public partial class ShopBuildMoney : System.Web.UI.Page
    {
        MessageBox box = new MessageBox();
        protected ST_ShopBuildMoney model = null;
        protected ST_Shop shop = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string shopid = Request.QueryString["id"] ?? "";
                if (!Page.IsPostBack)
                {
                    if (shopid != "")
                    {
                        shop = new ST_ShopBLL().GetModel(Convert.ToInt32(shopid));
                        model = new ST_ShopBuildMoneyBLL().GetModelbyID(Convert.ToInt32(shopid));
                    }
                    if (shop==null || model==null)
                    {
                        MessageBox_Page McBx = new MessageBox_Page();//实例化对话框
                        string RemarkString;
                        RemarkString = "未找到对象";

                        McBx.Title = "系统提示";
                        McBx.AddContent(RemarkString);
                        McBx.Type = MsgType.Error;
                        McBx.AddUrl("返回", "../../Module/InvestmentIncome/Storebuilding.aspx", UrlType.Href);
                        MessageEvent.MessageBox(McBx, "../../ErrorPage/ShowMsg.aspx");
                    }
                    //投资者下的所有门店
                    ddlistShop.DataSource = new ST_ShopBLL().GetListbyID(Method.CurrentUserID);
                    ddlistShop.DataTextField = "STitle";
                    ddlistShop.DataValueField = "ID";
                    ddlistShop.DataBind();
                    ddlistShop.SelectedValue = shop.ID.ToString();
                }
            }
            catch(ThreadAbortException) {}
            catch (Exception ex)
            {
                MessageBox_Page McBx = new MessageBox_Page();//实例化对话框
                string RemarkString;
                RemarkString = ex.Message;

                McBx.Title = "系统提示";
                McBx.AddContent(RemarkString);
                McBx.Type = MsgType.Error;
                McBx.AddUrl("返回", "../../Module/InvestmentIncome/Storebuilding.aspx", UrlType.Href);
                MessageEvent.MessageBox(McBx, "../../ErrorPage/ShowMsg.aspx");
            }
        }

        protected void ddlistShop_SelectedIndexChanged(object sender, EventArgs e)
        {
            shop = new ST_ShopBLL().GetModel(Convert.ToInt32(this.ddlistShop.SelectedValue));
            model = new ST_ShopBuildMoneyBLL().GetModelbyID(Convert.ToInt32(this.ddlistShop.SelectedValue));
            if (shop == null || model == null)
            {
                MessageBox_Page McBx = new MessageBox_Page();//实例化对话框
                string RemarkString;
                RemarkString = "未找到对象";

                McBx.Title = "系统提示";
                McBx.AddContent(RemarkString);
                McBx.Type = MsgType.Error;
                McBx.AddUrl("返回", "../../Module/InvestmentIncome/Storebuilding.aspx", UrlType.Href);
                MessageEvent.MessageBox(McBx, "../../ErrorPage/ShowMsg.aspx");
            }
        }
    }
}